package com.qf.fmall2302.shopcart.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.fmall2302.shopcart.entity.UserAddr;
import com.qf.fmall2302.shopcart.service.IUserAddrService;
import com.qf.fmall2302.utils.FmallConstants;
import com.qf.fmall2302.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户地址  前端控制器
 * </p>
 *
 * @author dongjl
 * @since 2023-08-24
 */
@RestController
@RequestMapping("/useraddr")
@CrossOrigin
@Slf4j
public class UserAddrController {

    @Autowired
    IUserAddrService userAddrService;

    @GetMapping("/list")
    public ResultVo list( Integer userId){

        log.info("入参为:userid={}",userId);

        List<UserAddr> userAddrList = userAddrService.list(new QueryWrapper<UserAddr>().eq("user_id", userId));

        return ResultVo.ok(FmallConstants.SUCCESS_CODE, FmallConstants.SUCCESS_MSG, userAddrList);

    }

}
